<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
    <title>2018/12/4</title>
    <!--好的代码像粥一样,是得用时间和精力熬的。-->
</head>
<body>
<input type="text" id="userName">
<br>
<span id="uName"></span>
<script>
    var obj = {
        pwd:'12345'
    };
    Object.defineProperty(obj,'userName',{
        value:'jack',
        set: function(){
           console.log('get init');
        },
        get:function(){
            console.log('set init');
        }
    });
    document.getElementById('userName').addEventListener('keyup',function(){
        document.getElementById('uName').innerText = event.target.value;
    });
</script>
</body>

</html>
